              package com.java.diagnostics.visualizer.impl.util.weak;
              
              import java.util.Collection;
              import java.util.Iterator;
              import java.util.Map;
              import java.util.Set;
              import java.util.WeakHashMap;
              
              public class WeakHashSet
                implements Set
              {
                private Map map;
              
                public WeakHashSet()
                {
                  this.map = new WeakHashMap();
                }
              
                public boolean add(Object arg0)
                {
                  if ((this.map.containsKey(arg0)) || (arg0 == null)) {
                    return false;
                  }
                  this.map.put(arg0, null);
                  return true;
                }
              
                public boolean addAll(Collection arg0)
                {
                  Iterator it = arg0.iterator();
                  boolean changed = false;
                  while (it.hasNext()) {
                    boolean result = add(it.next());
                    changed = (changed) || (result);
                  }
              
                  return changed;
                }
              
                public void clear()
                {
                  this.map.clear();
                }
              
                public boolean contains(Object arg0)
                {
                  return this.map.containsKey(arg0);
                }
              
                public boolean containsAll(Collection arg0)
                {
                  Iterator keys = arg0.iterator();
                  boolean contains = true;
                  while ((contains) && (keys.hasNext())) {
                    contains = this.map.containsKey(keys.next());
                  }
                  return contains;
                }
              
                public boolean isEmpty()
                {
                  return this.map.isEmpty();
                }
              
                public Iterator iterator()
                {
                  return this.map.keySet().iterator();
                }
              
                public boolean remove(Object arg0)
                {
                  if (this.map.containsKey(arg0)) {
                    this.map.remove(arg0);
                    return true;
                  }
                  return false;
                }
              
                public boolean removeAll(Collection arg0)
                {
                  Iterator it = arg0.iterator();
                  boolean changed = false;
                  while (it.hasNext()) {
                    boolean result = remove(it.next());
                    changed = (changed) || (result);
                  }
              
                  return changed;
                }
              
                public boolean retainAll(Collection arg0)
                {
                  return this.map.keySet().retainAll(arg0);
                }
              
                public int size()
                {
                  return this.map.size();
                }
              
                public Object[] toArray()
                {
                  return this.map.keySet().toArray();
                }
              
                public Object[] toArray(Object[] arg0)
                {
                  return this.map.keySet().toArray(arg0);
                }
              }

